<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>


	<form action="${pageContext.request.contextPath }/springmvc/testConverter" method="post">
		<!-- 字符串的格式为：GG-gg@csii.com-0-105 -->
		Employee : <input type="text" name="employee"/>
				   <input type="submit"/>
	</form>


	<%
		Map<Integer,Object> genders = new HashMap<>();
		genders.put(0, "Male");
		genders.put(1, "Female");
		request.setAttribute("genders", genders);
	%>
	
	<form:form action="${pageContext.request.contextPath }/employee/emp" method="post" modelAttribute="employee">
		<table>
			<c:if test="${id == null }">
			<tr>
				<td>LastName:</td>
				<td><form:input path="lastName"/></td>
				<td><form:errors path="lastName"/></td>
			</tr>
			</c:if>
			
			<c:if test="${id != null }">
				<form:hidden path="id"/>
				<input type="hidden" name="_method" value="PUT"/>
			</c:if>
			
			<tr>
				<td>Birth:</td>
				<td><form:input path="birth"/> </td>
				<td><form:errors path="birth"/></td>
			</tr>
			
			<tr>
				<td>Salary:</td>
				<td><form:input path="salary"/> </td>
				<td><form:errors path="salary"/></td>
			</tr>
			
			<tr>
				<td>Email:</td>
				<td><form:input path="email"/></td>
				<td><form:errors path="email"/></td>
			</tr>
			<tr>
				<td>Gerder:</td>
				<td><form:radiobuttons path="gerder" items="${requestScope.genders }"/></td>
			</tr>
			<tr>
				<td>Department:</td>
				<td><form:select path="department.id" items="${requestScope.departments }"
					itemValue="id" itemLabel="departmentName"/></td>
			</tr>
			
		</table>
		<input type="submit"/>
	</form:form>

</body>
</html>